import React from 'react'
import * as UI from 'antd-mobile'
import * as ICON from 'antd-mobile-icons'

import request from '@/services/request'

// 引入cookie
import cookies from 'react-cookies'

// 在React的框架下自定义全局的属性，用来放我们自己的东西
React.UI = UI
React.ICON = ICON
React.request = request
React.cookies = cookies

//客户资料信息
React.business = <object | null>React.cookies.load('business') ?? {}

// 成功和失败的提醒方法
React.toast = (msg: string, callback?: any, type?: string):void => 
{
    React.UI.Toast.show({
        icon: type ? type : 'success',
        content: msg,
        duration: 1500,
        afterClose: () => 
        {
            if(!callback) return;

            if(typeof callback === "string") callback === "back" ? React.navigate(-1) : React.navigate(callback)
            else callback()
        }
    })
}

//不需要登录的路由地址
React.RouterRules = [
    '/',
    '/business/login'
]

export default {}